#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

char *const argv[] = {
	(char*const)"ls",
	(char*const)"-a",
	(char*const)"-l",
	NULL};
extern char **environ;

int main()
{
	printf("程序运行!\n");
	pid_t childpid = fork();
	if(childpid == 0)
	{
		printf("子程序运行\n");
		printf("I am Child, My Pid Is: %d\n", getpid());
		sleep(1);
     		execvpe("/usr/bin/ls", argv, environ);
		printf("子程序运行完毕\n");
	}
	waitpid(-1, NULL, 0);
	printf("父程序运行完毕\n");
	return 0;
}
